<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="/Home/css/style.css" />

    <script type="text/javascript" src="/Home/js/menu.js"></script>    
            
	<script type="text/javascript" src="/Home/js/lrscroll_1.js"></script>

     
    
	<script type="text/javascript" src="/Home/js/n_nav.js"></script>
    
    <link rel="stylesheet" type="text/css" href="/Home/css/ShopShow.css" />
    <link rel="stylesheet" type="text/css" href="/Home/css/MagicZoom.css" />
    <script type="text/javascript" src="/Home/js/MagicZoom.js"></script>
    

    <script type="text/javascript" src="/Home/js/p_tab.js"></script>
    
    <script type="text/javascript" src="/Home/js/shade.js"></script>
    <script type="text/javascript" src="/Home/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="/Home/js/menu.js"></script>    

        
    
<title>尤洪</title>
</head>
<body>  
<!--Begin Header Begin-->
@include('Home.parent')
<div class="top">
    <div class="logo"><a href="http://www.nbshop.com"><img src="/Home/images/logo.png" /></a></div>
    <div class="search">
    	<form>
        	<input type="text" value="" class="s_ipt" />
            <input type="submit" value="搜索" class="s_btn" />
        </form>                      
        <span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a href="#">新鲜美食</a><a href="#">蛋糕</a><a href="#">日用品</a><a href="#">连衣裙</a></span>
    </div>
    <div class="i_car">
    	<div class="car_t">购物车 [ <span>3</span> ]</div>
        <div class="car_bg">
       		<!--Begin 购物车未登录 Begin-->
        	<div class="un_login">还未登录！<a href="login" style="color:#ff4e00;">马上登录</a> 查看购物车！</div>
            <!--End 购物车未登录 End-->
            <!--Begin 购物车已登录 Begin-->
            <ul class="cars">
            	<li>
                	<div class="img"><a href="#"><img src="/Home/images/car1.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">法颂浪漫梦境50ML 香水女士持久清新淡香 送2ML小样3只</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
                <li>
                	<div class="img"><a href="#"><img src="/Home/images/car2.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
                <li>
                	<div class="img"><a href="#"><img src="/Home/images/car2.jpg" width="58" height="58" /></a></div>
                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>
                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>
                </li>
            </ul>
            <div class="price_sum">共计&nbsp; <font color="#ff4e00">￥</font><span>1058</span></div>
            <div class="price_a"><a href="#">去购物车结算</a></div>
            <!--End 购物车已登录 End-->
        </div>
    </div>
</div>
<!--End Header End--> 
<!--Begin Menu Begin-->
<div class="menu_bg">
    <div class="menu">
        <!--Begin 商品分类详情 Begin-->    
        <div class="nav">
            <div class="nav_t">全部商品分类</div>
               <div class="leftNav">
               @if(empty($ak))
                <?php $ak=array();?>
               @else
                   @foreach ($ak as $key => $value)   
                       <ul> 
                           <li>
                            <div class="fj">
                                <span class="n_img"><span></span><img src="/Home/images/nav1.png" /></span>
                                   <span class="fl"   >{{$value->cate_name}}</span>
                               </div>
                               <div class="zj" style='top:{{$key*(-40)}}px';>
                                   <div class="zj_l">
                                   @if(empty($value->child))
                                      <?php $value->child=array();?>
                                   @else
                                       @foreach ($value->child as $k) 
                                           <div class="zj_l_c">
                                              <h2>{{$k->cate_name}}</h2>
                                              @if(empty($k->child))
                                                  <?php $k->chlid=array();?>
                                              @else
                                                  @foreach ($k->child as $v) 
                                                   <a href="home/categorylist">{{$v->cate_name}}</a>|
                                                  @endforeach 
                                              @endif
                                           </div>
                                      @endforeach 
                                  @endif
                                   </div>
                                   <div class="zj_r">
                                       <a href="#"><img src="/Home/images/n_img1.jpg" width="236" height="200" /></a>
                                       <a href="#"><img src="/Home/images/n_img2.jpg" width="236" height="200" /></a>
                                   </div>
                               </div>
                           </li>
                       </ul>  
                         @endforeach  
                     @endif        
               </div>
           </div>  
           <!--End 商品分类详情 End-->                                                     
        <ul class="menu_r">                                                                                                                                               
            <li><a href="http://www.nbshop.com">首页</a></li>
               <li><a href="Food.html">美食</a></li>
               <li><a href="Fresh.html">生鲜</a></li>
               <li><a href="HomeDecoration.html">家居</a></li>
               <li><a href="SuitDress.html">女装</a></li>
               <li><a href="MakeUp.html">美妆</a></li>
               <li><a href="Digital.html">数码</a></li>
               <li><a href="GroupBuying.html">汽车</a></li>
           </ul>
           <div class="m_ad">NBshop！</div>
    </div>
</div>
<!--End Menu End--> 
<div class="i_bg">
	<div class="postion">

    </div>    
    <div class="content">
    	                    
        <div id="tsShopContainer">
            <div id="tsImgS"><a href="<?php echo $Goodsinfo['goods_img'] ?>" title="Images" class="MagicZoom" id="MagicZoom"><img src="<?php echo $Goodsinfo['goods_img'] ?>" width="390" height="390" /></a></div>
            <div id="tsPicContainer">
                <div id="tsImgSArrL" onclick="tsScrollArrLeft()"></div>
                <div id="tsImgSCon">
                    <ul>
                        <li onclick="showPic(0)" rel="MagicZoom" class="tsSelectImg"><img src="<?php echo $Goodsinfo['goods_img'] ?>" tsImgS="<?php echo $Goodsinfo['goods_img'] ?>" width="79" height="79" /></li>

                    </ul>
                </div>
                <div id="tsImgSArrR" onclick="tsScrollArrRight()"></div>
            </div>
            <img class="MagicZoomLoading" width="16" height="16" src="/Home/images/loading.gif" alt="Loading..." />				
        </div>
        
        <div class="pro_des">
        	<div class="des_name">
            	<p><?php echo $Goodsinfo['goods_name'] ?></p>
                <input type="hidden" value="<?php echo $Goodsinfo['goods_id'] ?>" id='goods_id'/>
                <?php echo $Goodsinfo['goods_desc'] ?>
                <input type="hidden" value="<?php echo $Goodsinfo['goods_sn'] ?>" id='goods_sn'/>
            </div>
            <div class="des_price">
            	本店价格：<b id="now-price-box">￥<?php echo $Goodsinfo['shop_price'] ?></b><br />
                <input type="hidden" id="price" value="<?php echo $Goodsinfo['shop_price'] ?>" />
                市场价格：<b>￥</b><b id="market-price"  style="text-decoration:line-through;"><?php echo $Goodsinfo['goods_price'] ?></b><br />
                   <input type="hidden" id="price" value="<?php echo $Goodsinfo['goods_price'] ?>" />
            </div>
            <?php foreach ($specList as $attr_value): ?>
            <div class="des_choice">
                <span class="fl"><?= $attr_value['attr_name']; ?>：</span>
                <ul>
                    <?php foreach ($attr_value['spec'] as $sp_value): ?>
                    <li class="spec-li" data-id="<?= $sp_value['goods_attr_id']; ?>" data-price="<?= $sp_value['attr_price']; ?>"><?= $sp_value['attr_value']; ?><div class="ch_img"></div></li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <?php endforeach; ?>
            <div class="des_share">

                <div class="d_care"><a href="/home/addcollect/<?php echo $Goodsinfo['goods_id'] ?>">关注商品</a></div>
            </div>
            <div class="des_join">
            	<div class="j_nums">
                	<input type="text" value="1" name="" class="n_ipt" />
                    <input type="button" value="" onclick="addUpdate(jq(this));" class="n_btn_1" />
                    <input type="button" value="" onclick="jianUpdate(jq(this));" class="n_btn_2" />   
                </div>
                <span class="fl"><a href="javascript:;" class="addcart" ><img src="/Home/images/j_car.png" /></a></span>
            </div>            
        </div>    
        
        
    </div>


    <!--Begin 弹出层-加入购物车 Begin-->
    <div id="fade1" class="black_overlay"></div>
    <div id="MyDiv1" class="white_content">             
        <div class="white_d">
            <div class="notice_t">
                <span class="fr" style="margin-top:10px; cursor:pointer;" onclick="CloseDiv_1('MyDiv1', 'fade1')"><img src="/Home/images/close.gif" /></span>
            </div>
            <div class="notice_c">

                <table border="0" align="center" cellspacing="0" cellpadding="0">
                    <tr valign="top">
                        <td width="40"><img src="/Home/images/suc.png" /></td>
                        <td>
                            <span style="color:#3e3e3e; font-size:18px; font-weight:bold;">宝贝已成功添加到购物车</span><br />
                            购物车共商品（<span id="cart-count">0</span>件） &nbsp; &nbsp; 合计：<span id="cart-sum-price"></span>元
                        </td>
                    </tr>
                    <tr height="50" valign="bottom">
                        <td>&nbsp;</td>
                        <td><a href="/home/buycar" class="b_sure">去购物车结算</a><a href="http://www.nbshop.com" class="b_buy"  onclick="CloseDiv_1('MyDiv1', 'fade1')">继续购物</a></td>
                    </tr>
                </table>

            </div>
        </div>
    </div>   

    <div class="btmbg">
		<div class="btm">
        	备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com   Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group <br />
            <img src="/Home/images/b_1.gif" width="98" height="33" /><img src="/Home/images/b_2.gif" width="98" height="33" /><img src="/Home/images/b_3.gif" width="98" height="33" /><img src="/Home/images/b_4.gif" width="98" height="33" /><img src="/Home/images/b_5.gif" width="98" height="33" /><img src="/Home/images/b_6.gif" width="98" height="33" />
        </div>    	
    </div>
    <!--End Footer End -->    
</div>
<!--Begin 弹出层-加入购物车 Begin-->


</body>

<script src="/Home/js/ShopShow.js"></script>
    <script type="text/javascript" src="/Home/js/n_nav.js"></script>
    <script type="text/javascript" src="/Home/js/MagicZoom.js"></script>
    <script src="/Home/js/ShopShow.js"></script>
    <script type="text/javascript" src="/Home/js/num.js">
                    var jq = jQuery.noConflict();
    </script>

    <script type="text/javascript" src="/Home/js/shade.js"></script>

</html>
    <script type="text/javascript" src="/Home/js/jquery-1.8.2.min.js"></script>
<script>
//默认选中
    var auto_checked = '<?= $attr ?>';
    autochecked(auto_checked);
    function autochecked(auto_checked){
        var spec = auto_checked.split("|");
       $.each(spec,function(){
            $('.spec-li[data-id="'+this+'"]').addClass('checked').siblings().removeClass('checked');
       });
       //更新价格 获取所有规格的价钱 加上当前的价钱 等于新价钱
       updatePrice();
    }
    function updatePrice(){
        //获取市场价和本店价
        var market = parseFloat(<?php echo $Goodsinfo['goods_price'] ?>);
        var price = parseFloat($("#price").val());
        var spec = $('.checked');
        //当前价加上所选中规格的钱则成为最新的价钱
        for(var i=0; i<spec.length;i++){
            price+=parseFloat(spec.eq(i).data('price'));
            market+=parseFloat(spec.eq(i).data('price'));
        }
        $('#now-price-box').html('￥'+price);
        $('#market-price').html(market); 
    }
    //点击规格参数变换价格和提示信息 默认选中
    $('.des_choice').on('click','li',function(){
        //当前选择规格的id 为数组
        var spec_checked_id =[];
          //当前商品id
        var goods_id = $('#goods_id').val();
        var spec_parent = $(this).parents('.des_choice');//当前规格的盒子
        var prev_spec = spec_parent.prevAll('.des_choice').find('.checked');//当前规格的盒子之前的规格盒子
      
        //如果有上一级就把id放到数组里
        for(var i=0;i<prev_spec.length;i++){
            spec_checked_id.push(prev_spec.eq(i).data('id'));
        }
        //将当前点击li的id放到数组里
        spec_checked_id.push($(this).data('id'));
        //转换成字符串 以|形式
        spec_checked_id =spec_checked_id.join('|');
        //判断当前的规格是否还有下级规格  判断当前规格的div 有没有 class=des_choice
       if(spec_parent.nextAll('.des_choice').length>0){
            //有：在规格id 后面拼上“|”
            spec_checked_id+='|';
       }
       //发送ajax查询
       $.ajax({
            url:"/home/checkAttr/"+goods_id+'/'+'product_attr/'+spec_checked_id,
            type:'get',
            dataType:'json',
            success:function(msg){
               if(msg==2){
                    alert('当前库存不足，请选择其他规格');
                    return false;
               }
                //如果有数据则查看以下没有的   //隐藏下级所有规格
                spec_parent.nextAll('.des_choice').find('.spec-li').hide();
               //显示当前规格下可选的规格
                $.each(msg,function(k,v){
                    if(k==0){
                        autochecked(v);
                    }
                    var spec_arr = v.split('|');
                    $.each(spec_arr,function(kk,vv){
                        $('.spec-li[data-id="'+vv+'"]').show();
                    })

                });

            }
       })
    
    })

    //添加到购物车
    $('.addcart').on('click',function(){
      // alert(0);
        //当前商品id
        var goods_id = $('#goods_id').val();

        //获取当前页面上所有选中的属性
        var checked_li = $('.checked');
        var product_attr = [];//创建一个新数组 链接所有的选中的属性 下面转换成字符串
        for(var i = 0; i < checked_li.length; i++){
            product_attr.push(checked_li.eq(i).data('id'));
        }
        product_attr = product_attr.join('|');
       //获取商品数量
       var buy_nums = parseInt($('.n_ipt').val());
       //发送ajax查询
       $.ajax({
            url:"/home/addCart/"+goods_id+'/'+'product_attr/'+product_attr+'/buy_nums/'+buy_nums,
            type:'get',
            dataType:'json',
            success:function(msg){
              if(msg==1){
                alert("您还没登录,请先登录！！！");window.location.href="/home/login";
              }else if(msg==2){
                 alert("货品不足,请选择其他货品");
              }else if(msg==4){
                alert('您已添加过该商品');
              }else if(msg==3){
                alert("商品库存不足,请选择其他商品");
              }else{
                $('#cart-count').html(msg.buy_num);
                // $('.b_sure').html(msg.buy_num);
                $('#cart-sum-price').html(msg.goods_sum_price);
                ShowDiv_1('MyDiv1','fade1');
              }
            }
       })
            
    })

    function ShowDiv_1(show_div,bg_div){
        document.getElementById(show_div).style.display='block';
        document.getElementById(bg_div).style.display='block' ;
        var bgdiv = document.getElementById(bg_div);
        bgdiv.style.width = document.body.scrollWidth;
        // bgdiv.style.height = $(document).height();
        $("#"+bg_div).height($(document).height());
    };

</script>
